package com.sdry.service.impl.zc;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.sdry.mapper.zc.ZcJzSpotCheckMapper;
import com.sdry.model.zc.ZcJzSpotCheckDetailsEntity;
import com.sdry.model.zc.ZcJzSpotCheckEntity;
import com.sdry.model.zc.ZcQueryCriteria;
import com.sdry.service.zc.ZcJzSpotCheckService;

/**
 * 
 * @ClassName:    ZcJzSpotCheckServiceImpl   
 * @Description:  浇铸抽检
 * @Author:       zc   
 * @CreateDate:   2018年10月19日 上午10:44:44   
 * @Version:      v1.0
 */
@Service
public class ZcJzSpotCheckServiceImpl implements ZcJzSpotCheckService {

	@Resource
	private ZcJzSpotCheckMapper zcJzSpotCheckMapper;
	/**
	 * 查询浇铸抽检单列表
	 */
	@Override
	public List<ZcJzSpotCheckEntity> selectJzSpotCheckList(ZcQueryCriteria zcQueryCriteria) {
		return zcJzSpotCheckMapper.selectJzSpotCheckList(zcQueryCriteria);
	}
	/**
	 * 查询浇铸抽检单列表数目
	 */
	@Override
	public int countJzSpotCheckList(ZcQueryCriteria zcQueryCriteria) {
		return zcJzSpotCheckMapper.countJzSpotCheckList(zcQueryCriteria);
	}
	/**
	 * 保存浇铸抽检记录
	 */
	@Override
	public int inserJzSpotCheck(ZcJzSpotCheckEntity zcJzSpotCheckEntity) {
		return zcJzSpotCheckMapper.insertJzSpotCheck(zcJzSpotCheckEntity);
	}
	/**
	 * 删除浇铸抽检单
	 */
	@Override
	public int delJzSpotCheckArr(long id) {
		return zcJzSpotCheckMapper.delJzSpotCheckArr(id);
	}
	/**
	 * 修改浇铸抽检单
	 */
	@Override
	public int updateJzSpotCheck(ZcJzSpotCheckEntity zcJzSpotCheckEntity) {
		return zcJzSpotCheckMapper.updateJzSpotCheck(zcJzSpotCheckEntity);
	}
	/**
	 * 保存浇铸抽检详情
	 */
	@Override
	public int insertJzSpotCheckDetails(ZcJzSpotCheckDetailsEntity zcJzSpotCheckDetailsEntity) {
		String checkItemAll = zcJzSpotCheckDetailsEntity.getCheckItem();
		String checkItemArr[] = checkItemAll.split(",",-1);
		String standardValueAll = zcJzSpotCheckDetailsEntity.getStandardValue();
		String standardValueArr[] = standardValueAll.split(",",-1);
		String realityValueAll = zcJzSpotCheckDetailsEntity.getRealityValue();
		String realityValueArr[] = realityValueAll.split(",",-1);
		String ideaAll = zcJzSpotCheckDetailsEntity.getIdea();
		String ideaArr[] = ideaAll.split(",",-1);
		String remarkAll = zcJzSpotCheckDetailsEntity.getRemark();
		String remarkArr[] = remarkAll.split(",",-1);
		int length = checkItemArr.length;
		int affact = 0;
		for(int i = 0;i < length;i++){
			zcJzSpotCheckDetailsEntity.setCheckItem(checkItemArr[i]);
			zcJzSpotCheckDetailsEntity.setStandardValue(standardValueArr[i]);
			zcJzSpotCheckDetailsEntity.setRealityValue(realityValueArr[i]);
			zcJzSpotCheckDetailsEntity.setIdea(ideaArr[i]);
			zcJzSpotCheckDetailsEntity.setRemark(remarkArr[i]);
			affact += zcJzSpotCheckMapper.insertJzSpotCheckDetails(zcJzSpotCheckDetailsEntity);
		}	
		return affact;
	}
	/**
	 * 通过检测序号查询详情列表
	 */
	@Override
	public List<ZcJzSpotCheckDetailsEntity> selectJzSpotCheckDetailsListByNumber(ZcQueryCriteria zcQueryCriteria) {
		return zcJzSpotCheckMapper.selectJzSpotCheckDetailsListByNumber(zcQueryCriteria);
	}
	/**
	 * 通过检测序号查询详情列表数目
	 */
	@Override
	public int countJzSpotCheckDetailsListByNumber(ZcQueryCriteria zcQueryCriteria) {
		return zcJzSpotCheckMapper.countJzSpotCheckDetailsListByNumber(zcQueryCriteria);
	}
	/**
	 * 查询浇铸抽检统计表
	 * @param zcQueryCriteria
	 * @return
	 */
	@Override
	public List<ZcJzSpotCheckDetailsEntity> selectJzSpotCheckStatisticsTable(ZcQueryCriteria zcQueryCriteria) {
		return zcJzSpotCheckMapper.selectJzSpotCheckStatisticsTable(zcQueryCriteria);
	}
	/**
	 * 查询浇铸抽检统计表数量
	 * @param zcQueryCriteria
	 * @return
	 */
	@Override
	public int countJzSpotCheckStatisticsTable(ZcQueryCriteria zcQueryCriteria) {
		return zcJzSpotCheckMapper.countJzSpotCheckStatisticsTable(zcQueryCriteria);
	}
	/**
	 * 通过编码查型号
	 */
	@Override
	public String selectPcarByNumber(String number) {
		return zcJzSpotCheckMapper.selectPcarByNumber(number);
	}
}
